<?PHP
@session_start();
require("../inc/common.inc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
$action=$_GET['action'];
	if($action=="check"){
		$CheckCode=$_COOKIE['CheckCode'];

		$postnum=$_POST['CheckCode'];
		$name=$_POST['UserName'];
		$pwd=$_POST['Password'];

		if($name==""){
			$fun->popmassage("用户名为空","Login.php","popgotourl");
			exit();
		}
		if($pwd==""){
			$fun->popmassage("密码为空","Login.php","popgotourl");
			exit();
		}
		if($postnum!=$CheckCode){
			$fun->popmassage("验证码不正确","Login.php","popgotourl");
			exit();
		}
		
		
		$pwd=md5($pwd);
		///判断用户名和密码是否正确
		$usernum=$db->excu("SELECT * FROM mx_members WHERE username='$name' and password='$pwd' ");
		if($db->num_rows($usernum)!=1){
			$fun->popmassage("密码或用户名不正确","Login.php","popgotourl");
			exit();
		}else{
            $usernum=$db->fetch_array($usernum);
			if ($usernum["username"]!=trim($name) or $usernum["password"]!=trim($pwd)){
				$fun->popmassage("密码或用户名不正确","Login.php","popgotourl");
				exit();	
			}
			if ($usernum["isok"]==0){
				$fun->popmassage("此用户已经被禁用","Login.php","popgotourl");
				exit();	
			}
			if (trim($usernum["realname"])==""){$usernum["realname"]=$usernum["username"];}
			
			session_cache_expire(30);
			$_SESSION['mxadmin']['username']=$name;
			$_SESSION['mxadmin']['realname']=$usernum["realname"];
			$_SESSION['mxadmin']['userid']=$usernum["uid"];
			$_SESSION['mxadmin']['purview']=$usernum["Purview"];
			$_SESSION['mxadmin']['password']=$usernum[password];
			
			////写入登陆日志
			$ip=$_SERVER['REMOTE_ADDR'];
			$date=date("Y-m-d H:i:s");
			$sql="insert into mx_members_log (userid,username,times,ip) values ('$usernum[uid]','$name','$date','$ip')";
			$db->excu($sql);
			//修改登陆信息
			$sql="update mx_members set LoginTimes=LoginTimes+1,LastLoginIP='$ip',LastLoginTime='$date'  where username='$name' and password='$pwd'";

			$db->excu($sql);
			////
			$fun->popmassage("","Default.php","gotourl");
			exit();
		}
		
}

		  ?>
<TITLE>山东微信营销中心  铭讯微信一佳</TITLE>
<Meta name="Keywords" Content="山东微信营销中心  铭讯微信一佳">
<Meta name="Description" Content="山东微信营销中心  铭讯微信一佳">
<style type="text/css">
body{background:url(images/login_1.jpg) center top no-repeat; margin:0px; padding:0px; border:0px;}
#f_div{ min-width:100%; min-height:480px; overflow:hidden; margin:auto; position:absolute; margin-top:-240px; top:50%;}
#f_div #l_logo{width:288px;height:93px;background:url(images/login_6.png) 0 0 no-repeat;margin:0px auto 0;}
#f_div #l_zong{background:url(images/login_2.png) center 50% no-repeat;margin-top:15px;height:335px;}
#f_div #l_zong .kuang{width:463px;margin:0px auto;height:271px;font-size:14px;color:#666;background:url(images/login_3.png) 0 0 no-repeat;padding-top:64px;}
#f_div #l_zong .kuang a{font-size:12px;color:#39f;}
.w296{width:296px;height:31px;border:#ccc 1px solid;line-height:31px; font-size:16px; font-weight:bold;}
.w85{width:85px;height:31px;border:#ccc 1px solid;line-height:31px; font-size:16px; font-weight:bold;}
#l_bottom{ text-align:center;font-size:12px;color:#999;margin-top:30px;}
</style>
<!--[if lte IE 6]>
<script src="js/DD_belatedPNG_0.0.8a.js" type="text/javascript"></script>
    <script type="text/javascript">
        DD_belatedPNG.fix('div, ul, img, li, input , a, cite, em');
    </script>
<![endif]--> 
</head>

<body>
<div id="f_div">
<div id="l_logo"></div>
<div id="l_zong">
	<div class="kuang">
	  <form name="Login" action="Login.php?action=check" method="post" target="_parent" onSubmit="return CheckForm();">
	    <table width="87%" border="0" align="center" cellpadding="10" cellspacing="0">
          <tr>
            <td width="23%" align="right">账　号：</td>
            <td width="77%"><input type="text" name="UserName" id="UserName" class="w296" /></td>
          </tr>
          <tr>
            <td align="right">密　码：</td>
            <td><input type="password" name="Password" id="Password" class="w296" /></td>
          </tr>
          <tr>
            <td align="right">验证码：</td>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="33%"><input type="text" name="CheckCode" id="CheckCode" class="w85" /></td>
                <td width="34%"><img border="0" name="imageField" id="imageField" src="code.php" onClick="this.src='code.php?dt='+Math.random();" style="cursor:pointer; " alt="看不清楚，换一张"></td>
                <td width="33%"><a href="javascript:document.getElementById('imageField').src='code.php?dt='+Math.random();">点击刷新</a></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td align="right"><input type="image" name="imageField" src="images/login_5.png" /></label></td>
          </tr>
        </table>
      </form>
    </div>
</div>
<div id="l_bottom">Copyright ©2013 微信一佳 Corporation, All Rights Reserved</div>
</div>

<script language=javascript>
function CheckForm()
{
	if(document.Login.UserName.value=="")
	{
		alert("请输入用户名！");
		document.Login.UserName.focus();
		return false;
	}
	if(document.Login.Password.value == "")
	{
		alert("请输入密码！");
		document.Login.Password.focus();
		return false;
	}
	if (document.Login.CheckCode.value==""){
       alert ("请输入您的验证码！");
       document.Login.CheckCode.focus();
       return(false);
    }
}
</script>
</body>
</html>
